<div id="content">

    <div id="content-header">

        <div id="breadcrumb"><a href="<?php echo site_url('Login/login') ?>" title="Go to Home" class="tip-bottom"><i
                class="icon-home"></i> 主页</a> <a href="#" class="current">用户管理</a></div>

        <h1>代理等级配置</h1>

    </div>
    <div class="container-fluid">

        <hr>

        <div class="row-fluid">
            <div class="span8">
                <!--修改数据表单/edit news form-->
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-align-justify"></i> </span>
                        <h5>配置等级权限</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <form action="<?php echo site_url('user/doEditAgent') ?>" method="post" class="form-horizontal">
                            <div class="control-group">
                                <label class="control-label">代理编号:</label>
                                <div class="controls">
                                    <input type="text" name='id' class="span6"  value="<?php echo $data[0]['id']?>" readonly="true">
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">代理账号:</label>
                                <div class="controls">
                                    <input type="text" name='level' class="span6"  value="<?php echo urldecode($data[0]['name'])?>" readonly="true">
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">代理等级:</label>
                                <div class="controls">
                                    <select name="Level" onchange="getSrsRate()">
                                        <?php
                            $rows=$data[2];
                            foreach($rows as $value):
                            ?>
                                        <option value="<?php echo $value['id']?>"><?php echo $value['level']?>
                                        </option>

                                        <?php    endforeach; ?>
                                    </select>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">返利等级:</label>
                                <div class="controls">
                                    <input type="text" name='ret' class="span4"
                                           disabled="disabled">
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">返利利率:</label>
                                <div class="controls">
                                    <input type="text" name='rate' class="span6"  disabled="disabled">
                                </div>
                            </div>
                            <div class="form-actions">
                                <button type="submit" class="btn btn-success">保存</button>
                            </div>
                        </form>
                    </div>
                </div>

                <!--修改数据表单/edit news form-->
            </div>
        </div>

    </div>

</div>
<script language="JavaScript">
    function getSrsRate() {
        var $value=$("select[name='Level']").val();
       var  $url=window.location.origin+'/admin/index.php/user/getSrsRate';
        $.post($url, { name: $value},
            function(data){
                $("input[name='ret']").val(data.rLevel);
               $("input[name='rate']").val(data.rebate_rate)
            },'json');
    }
</script>